//
//  ActivityVC.m
//  SchoolCircle
//
//  Created by 战立军 on 16/5/27.
//  Copyright © 2016年 战立军. All rights reserved.
//

#import "ActivityVC.h"
#import "ActivityButton.h"

#define BtnWH ([UIUTils getWindowWidth]-30*2)/3

@interface ActivityVC ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView *_tableView;
}
@end

@implementation ActivityVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNav];
    [self addContentView];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark 导航栏
- (void)setNav
{
    self.title = @"活动";
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"uitabr"]];
    // 设置导航默认标题的颜色及字体大小
    self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeTextColor: [UIColor whiteColor],
                                                                    UITextAttributeFont : [UIFont boldSystemFontOfSize:18]};
}

#pragma mark 添加视图
- (void)addContentView
{
    [self.view setBackgroundColor:[UIColor whiteColor]];
    if ([UIDevice currentDevice].systemVersion.floatValue >= 7) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }

    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 10, [UIUTils getWindowWidth], 100) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    [self.view addSubview:_tableView];
    
    ActivityButton *mood = [[ActivityButton alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(_tableView.frame)+10, BtnWH, BtnWH)];
    [mood setImage:[UIImage imageNamed:@"xinyuan"] andTitle:@"心愿"];
    mood.backgroundColor = Color(246, 246, 246);
    [mood addTarget:self action:@selector(moodButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:mood];
    
    ActivityButton *man = [[ActivityButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(mood.frame), CGRectGetMaxY(_tableView.frame)+10, BtnWH, BtnWH)];
    [man setImage:[UIImage imageNamed:@"man"] andTitle:@"男人帮"];
    [man addTarget:self action:@selector(manButtonPress) forControlEvents:UIControlEventTouchUpInside];
    man.backgroundColor = Color(246, 246, 246);
    [self.view addSubview:man];
    
    ActivityButton *move = [[ActivityButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(man.frame), CGRectGetMaxY(_tableView.frame)+10, BtnWH, BtnWH)];
    [move setImage:[UIImage imageNamed:@"move"] andTitle:@"新视角"];
    move.backgroundColor = Color(246, 246, 246);
    [move addTarget:self action:@selector(moveButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:move];
    
    ActivityButton *phone = [[ActivityButton alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(man.frame), BtnWH, BtnWH)];
    [phone setImage:[UIImage imageNamed:@"phone"] andTitle:@"电话"];
    phone.backgroundColor = Color(246, 246, 246);
    [phone addTarget:self action:@selector(phoneButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:phone];
    
    ActivityButton *around = [[ActivityButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(phone.frame), CGRectGetMaxY(man.frame), BtnWH, BtnWH)];
    [around setImage:[UIImage imageNamed:@"around"] andTitle:@"周边"];
    around.backgroundColor = Color(246, 246, 246);
    [around addTarget:self action:@selector(aroudButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:around];
    
    ActivityButton *news = [[ActivityButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(around.frame), CGRectGetMaxY(man.frame), BtnWH, BtnWH)];
    [news setImage:[UIImage imageNamed:@"news"] andTitle:@"新闻"];
    news.backgroundColor = Color(246, 246, 246);
    [news addTarget:self action:@selector(newsButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:news];
    
    
    ActivityButton *health = [[ActivityButton alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(news.frame), BtnWH, BtnWH)];
    [health setImage:[UIImage imageNamed:@"health"] andTitle:@"健康"];
    health.backgroundColor = Color(246, 246, 246);
    [health addTarget:self action:@selector(healthButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:health];
    
    ActivityButton *edducation = [[ActivityButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(health.frame), CGRectGetMaxY(news.frame), BtnWH, BtnWH)];
    [edducation setImage:[UIImage imageNamed:@"education"] andTitle:@"教育"];
    edducation.backgroundColor = Color(246, 246, 246);
    [edducation addTarget:self action:@selector(educatonButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:edducation];
    
    ActivityButton *love = [[ActivityButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(edducation.frame), CGRectGetMaxY(news.frame), BtnWH, BtnWH)];
    [love setImage:[UIImage imageNamed:@"love"] andTitle:@"爱情"];
    love.backgroundColor = Color(246, 246, 246);
    [love addTarget:self action:@selector(loveButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:love];
    
    
    
}


#pragma mark UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellidet = @"mycell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellidet];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellidet];
    }
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //显示最右边的箭头
    
    if (indexPath.row == 0) {
        cell.imageView.image = [UIImage imageNamed:@"friend"];
        cell.textLabel.text = @"我的好友";
        
    }else
    {
        cell.imageView.image = [UIImage imageNamed:@"group"];
        cell.textLabel.text = @"我的群组";
    }
    
    return cell;
}

#pragma mark tableDeleagte

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row ==0) {
        NSLog(@"我的好友");
        
    }else
    {
        NSLog(@"我的群组");
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


#pragma mark 活动
/**
 *  心情按钮
 */
- (void)moodButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  男人按钮
 */
- (void)manButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  电影按钮
 */
- (void)moveButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  电话按钮
 */
- (void)phoneButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  周边按钮
 */
- (void)aroudButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  新闻按钮
 */
- (void)newsButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  健康按钮
 */
- (void)healthButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  教育按钮
 */
- (void)educatonButtonPress
{
    NSLog(@"%s",__func__);
}
/**
 *  爱情按钮
 */
- (void)loveButtonPress
{
    NSLog(@"%s",__func__);
}




@end
